package com.cdcas;

import java.util.Objects;

public class BookHash {

    private String title;
    private String author;
    private double price;

    public BookHash(String title,String author,double price) {
        this.title = title;
        this.author = author;
        this.price = price;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null || getClass() !=obj.getClass()){
            return false;
        }
        BookHash bookHash= (BookHash) obj;
        return Double.compare(bookHash.price,price)==0 && title.equals(bookHash.title)
                && author.equals(bookHash.author);
    }

    @Override
    public int hashCode() {
        return Objects.hash(title,author,price);
    }

    @Override
    public String toString() {
        return "BookHash{" +
                "title='" + title + '\'' +
                ", author='" + author + '\'' +
                ", price=" + price +
                '}';
    }
}
